/*
* Change Logs:
* Date Author Notes
* 2021-06-03 qwz first version
*/
#ifndef __DRV_SOFT_SPI_H_
#define __DRV_SOFT_SPI_H_
#include <rtthread.h>
#include "rtdevice.h"
#include <rthw.h>
#include <drv_common.h>
//#include "ab32vg1_hal_gpio.h"

rt_err_t rt_soft_spi_device_attach(const char *bus_name, const char *device_name, hal_sfr_t cs_gpiox, rt_uint8_t cs_gpio_pin);

struct ab32_soft_spi_pin
{
 hal_sfr_t GPIOx;
 rt_uint8_t GPIO_Pin;
};
struct ab32_soft_spi_config
{
 rt_uint8_t mosi_pin;
rt_uint8_t miso_pin;
rt_uint8_t sclk_pin;
 char *bus_name;
};
struct ab32_soft_spi_device
{
 rt_uint8_t cs_pin;
 char *bus_name;
 char *device_name;
};
/* ab32 soft spi dirver class */
struct ab32_soft_spi
{
rt_uint8_t mode;
rt_uint8_t cpha;
rt_uint8_t cpol;
rt_uint8_t data_width;
rt_uint8_t msb;
rt_uint16_t dummy_data;
rt_uint32_t spi_delay;
rt_uint8_t max_hz;
 struct ab32_soft_spi_config *config;
 struct rt_spi_configuration *cfg;
 struct rt_spi_bus spi_bus;
};
#endif /*__DRV_SOFT_SPI_H_ */
